import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'limitApprovalM',

  state: {},

  effects: {
    //查询限额审批基本信息
    *queryLimitApprovalInfo({ payload, callback }, { call, put }) {
      const response = yield call(api.agencyTask.approvalList.queryLimitApprovalInfo, payload);
      if (response) {
        if (response.code == 0) {
          callback('success', response.data.dataSource || {});
        } else {
          callback('fail');
          message.error(response.msg || '查询限额审批基本信息失败!');
        }
      } else {
        callback('fail');
        message.error('查询限额审批基本信息失败!');
      }
    },
    //获取限额审批风险条目列表
    *queryLimitApprovalList({ payload, callback }, { call, put }) {
      const response = yield call(api.agencyTask.approvalList.queryLimitApprovalList, payload);
      if (response) {
        if (response.code == 0) {
          callback('success', response.data.dataSource || []);
        } else {
          callback('fail');
          message.error(response.msg || '查询限额审批风险条目失败!');
        }
      } else {
        callback('fail');
        message.error('查询限额审批风险条目失败!');
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
